﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace OnlineEducation.Data.Entities
{
    /// <summary>
    ///  课程计划. 教师先建立课程，然后发布计划，最后学生加入该计划
    /// </summary>
    /// <seealso cref="OnlineEducation.Data.Entities.EntityBase" />
    public class TeachingPlan : EntityBase
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 类别,1:正常计划,2:即时计划
        /// </summary>
        /// <value>
        /// The category.
        /// </value>
        public int Category { get; set; }//1:normal plan 2: adhoc plan

        [Display(Name = "开始时间")]
        [Required]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
        public DateTime BeginTime { get; set; }

        [Display(Name = "结束时间")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
        public DateTime EndTime { get; set; }

        [Display(Name = "计划名称")]
        [StringLength(200)]
        public string Name { get; set; }

        [ForeignKey("Course")]
        public int? CourseId { get; set; }
        /// <summary>
        /// 关联的课程
        /// </summary>
        /// <value>
        /// The course.
        /// </value>
        public Course Course { get; set; }

        [ForeignKey("Teacher")]
        public int? TeacherId { get; set; }
        /// <summary>
        /// 授课教师
        /// </summary>
        /// <value>
        /// The teacher.
        /// </value>
        public ApplicationUser Teacher { get; set; }

        [Display(Name = "课程公告")]
        [StringLength(100, ErrorMessage = "长度不能超过100")]
        public string Notification { get; set; }

        public List<TeachingPlanItem> TeachingPlanItems { get; set; }

        [Display(Name = "教学时间种类")]
        public int TeachingTimeOption { get; set; }//1 repeat by week,2 repeat by month,0 customize
        [Display(Name = "包含周末")]
        public bool IncludeWeekend { get; set; }
        [Display(Name = "包含国假")]
        public bool IncludeHoliday { get; set; }
        [Display(Name = "包含寒暑假")]
        public bool IncludeWSVacation { get; set; }

        public int TeachingTimeWeekday { get; set; }

        /// <summary>
        /// 状态(0:未开始,1:进行中,2:完成)
        /// </summary>
        /// <value>
        /// The status.
        /// </value>
        [Display(Name = "状态")]
        public int Status { get; set; }  

        [Display(Name = "开始时间")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
        public string TeachingTimeOptionStartTime { get; set; }

        /// <summary>
        /// 评价.
        /// </summary>
        /// <value>
        /// The evaluations.
        /// </value>
        public List<TeachingEvaluation> Evaluations { get; set; }

        [Display(Name = "教材")]
        [StringLength(400, ErrorMessage = "长度不能超过400")]
        public string MaterialURLs { get; set; }//PPT，word，pdf 


        [Display(Name = "招生数量")]
        public int StudentPlanCount { get; set; }

    }
    /// <summary>
    /// 详细课程计划
    /// </summary>
    /// <seealso cref="OnlineEducation.Data.Entities.EntityBase" />
    public class TeachingPlanItem : EntityBase
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [ForeignKey("Lesson")]
        public int? LessonId { get; set; }

        [ForeignKey("TeachingPlan")]
        public int TeachingPlanId { get; set; }

        public TeachingPlan TeachingPlan { get; set; }

        public Lesson Lesson { get; set; }

        [Display(Name = "开始时间")]
        [Required]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
        public DateTime BeginTime { get; set; }

        [Required]
        [StringLength(50)]
        public string MeetingNo { get; set; } = Guid.NewGuid().ToString();

        /// <summary>
        /// 状态(0:未开始,1:进行中,2:完成)
        /// </summary>
        /// <value>
        /// The status.
        /// </value>
        [Display(Name = "状态")]
        public int Status { get; set; }//0:无效,1:有效
    }


}
